# Maintainer: Jean-Michaël Celerier <jeanmichael.celerier at gmail dot com>

_realname=cninja
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=3.7.9
pkgrel=2
pkgdesc="An opinionated CMake config manager (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/jcelerier/cninja"
license=('spdx:AGPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-cmake"
         "${MINGW_PACKAGE_PREFIX}-clang"
         "${MINGW_PACKAGE_PREFIX}-lld"
         "${MINGW_PACKAGE_PREFIX}-ninja"
         "${MINGW_PACKAGE_PREFIX}-libc++")
makedepends=("${MINGW_PACKAGE_PREFIX}-boost" "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/jcelerier/cninja/releases/download/v${pkgver}/cninja-v${pkgver}-src.tar.gz")
sha512sums=('db3b409d0e0c5250134a550fee8658110319d4a795aede757c1399650081c439d36ff5d16dda3643b41c66940cf6e99fc7e5230339bbc55590522ba58f82e92b')

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}
 
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -GNinja \
    -Wno-dev \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
     "$srcdir"

  ${MINGW_PREFIX}/bin/cmake --build .
}

package() {
  cd "$srcdir/build-${MSYSTEM}"
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .

  install -D -m644 "$srcdir/LICENSE.md" "${pkgdir}${MINGW_PREFIX}/share/licenses/${pkgname}/LICENSE"
}
